﻿#region Copyrights Notice
//©2010 Microsoft Corporation. All rights reserved.
#endregion

#region usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.InformationSecurity.CISF.SecurityPortal.Business.Entities;
#endregion

namespace Microsoft.InformationSecurity.CISF.SecurityPortal.Business.Widget
{
    public class WidgetContainerBase
    {
        public IWidget ctrlWidgetControl;
        public WidgetInstance ctrlWidgetInstanceControl;
        public bool bLoadFirstTime;
        public string widgetPath;

        public WidgetInstance WidgetInstanceControl
        {
            get { return ctrlWidgetInstanceControl; }
            set { ctrlWidgetInstanceControl = value; }
        }

        int GetControlID()
        {
            return this.WidgetInstanceControl.WidgetInstanceId;
        }

        /* Begin - Implement IWidgetContainer */

        void SetState(string state, string userid)
        {
            //***** ANIL REMOVED THIS -- CHECK IF THIS IS NEEDED AT ALL IN  THE FIRST PLACE ********//

            ////Todo -  Update database...
            //var WidgetFacade = new WidgetFacade(userid);

            //if (!WidgetFacade.UpdateWidgetState(WidgetInstanceControl.WidgetId, state)) { } //Success
            //else { }//Failure.
        }

        string GetState()
        {
            return WidgetInstanceControl.State;
        }

        void ControlDisplaySettings(bool bShow)
        {
            this.ctrlWidgetControl.DisplaySettings(bShow);
        }

        public bool FirstTime
        {
            get { return bLoadFirstTime; }
            set { bLoadFirstTime = value; }
        }

        public string GetControlRelativeUrl()
        {
            return WidgetInstanceControl.Widget.Url;
        }

        public int GetControlID2()
        {
            return WidgetInstanceControl.WidgetInstanceId;
        }

        public string WidgetPath
        {
            get { return widgetPath; }
            set { widgetPath = value; }
        }
    }
}
